/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */ 
@isTest
private class TEST_CustomerSatisfactionSurvey {

	private controllerCustomerSatisfactionSurvey myCtrlCSS;	
	List<Customer_Satisfaction_Survey__c> myCSSList;
	
    static testMethod void myUnitTest() {
		System.debug(' ################## ' + 'BEGIN TEST_CustomerSatisfactionSurvey' + ' ################');
        Id myProfile = [select id from profile where name='System Administrator' limit 1].Id;
        System.debug(' ################## ' + 'myProfile: ' + myProfile + ' ################');
        //User myUser = [Select id from User where profileId =:myProfile and IsActive=true limit 1];
        User myUser = new User(alias = 'repuser', email='usertest@absi.be', emailencodingkey='UTF-8', lastname='Testing', 
        		languagelocalekey='en_US',localesidkey='en_US', profileid = myProfile, timezonesidkey='America/Los_Angeles', 
        		username='usertest@absi.be');        
        		
        System.runAs(myUser) {
        	System.debug('Current User: ' + UserInfo.getUserName());
		    System.debug('Current Profile: ' + UserInfo.getProfileId());
        	TEST_CustomerSatisfactionSurvey myTestController = new TEST_CustomerSatisfactionSurvey();
        	myTestController.createRecords();
        	myTestController.init();
        	myTestController.doTests();
        }
        
        System.debug(' ################## ' + 'END TEST_controllerDIB_Campaign' + ' ################');
    }
    
    public void init() {
    	System.debug(' ################## ' + 'TEST_controllerDIB_Campaign_init' + ' ################');
	    datetime currentDateTime = datetime.now();
		Sobject myCSS = myCSSList.get(1);
		ApexPages.StandardController newSct = new ApexPages.Standardcontroller(myCSS); //set up the standardcontroller
	  	myCtrlCSS = new controllerCustomerSatisfactionSurvey(newSct);
	  	myCtrlCSS.Init();	
    }
    
    public void doTests() {
    	myCtrlCSS.redirectToCustomerSatisfactionSurvey();
    }
    
	public void createRecords() {
	   	
			Contact cont1 = [Select Id from Contact limit 1];
		
			myCSSList = new List<Customer_Satisfaction_Survey__c>();

			Customer_Satisfaction_Survey__c myCSS;

			myCSS = new Customer_Satisfaction_Survey__c();
			myCSS.Contact__c = cont1.Id;
			myCSS.Survey_Month__c = '12';
			myCSS.Survey_Year__c = '2009';
			myCss.CustomerResponse1__c = 4;
			myCss.CustomerResponse2__c = 2;
			myCss.CustomerResponse3__c = 4;
			myCss.CustomerResponse4__c = 2;
			myCss.CustomerResponse5__c = 1;
			myCss.CustomerResponse6__c = '5';
			myCss.CustomerResponse7__c = 4;
			myCss.CustomerResponse8__c = 3;
			myCss.CustomerResponse9__c = '3';
			myCss.CustomerResponse10__c = 'Yes';
			myCss.CustomerResponse11__c = 'Yes';
			myCss.CustomerResponse12__c = 'Yes';
			myCss.CustomerResponse13__c = 'Yes';
			
			myCss.VCMresponse1__c = 4;
			myCss.VCMresponse2__c = 4;
			myCss.VCMresponse3__c = 4;
			myCss.VCMresponse4__c = 4;
			myCss.VCMresponse5__c = 4;
			myCss.VCMresponse6__c = '4';
			myCss.VCMresponse7__c = 4;
			myCss.VCMresponse8__c = 4;
			myCss.VCMresponse9__c = '4';
			myCss.VCMresponse_10__c = 'Yes';
			myCss.VCMresponse_11__c = 'Yes';
			myCss.VCMresponse_12__c = 'Yes';
			myCss.VCMresponse_13__c = 'Yes';
			myCSSList.add(myCSS);
			
			myCSS = new Customer_Satisfaction_Survey__c();
			myCSS.Contact__c = cont1.Id;
			myCSS.Survey_Month__c = '01';
			myCSS.Survey_Year__c = '2010';
			myCss.CustomerResponse1__c = 5;
			myCss.CustomerResponse2__c = 5;
			myCss.CustomerResponse3__c = 5;
			myCss.CustomerResponse4__c = 5;
			myCss.CustomerResponse5__c = 5;
			myCss.CustomerResponse6__c = '5';
			myCss.CustomerResponse7__c = 5;
			myCss.CustomerResponse8__c = 5;
			myCss.CustomerResponse9__c = '5';
			myCss.CustomerResponse10__c = 'Yes';
			myCss.CustomerResponse11__c = 'Yes';
			myCss.CustomerResponse12__c = 'Yes';
			myCss.CustomerResponse13__c = 'Yes';
			myCSSList.add(myCSS);
			
			insert myCSSList;

	}

}